<?php

/**
 * Created by PhpStorm.
 * User: Yieong
 * Date: 16/4/1
 * Time: 下午1:53
 */
class GuildService extends Service {

    public static function getInfo($server, $name){
        if(empty($name)){
            return array('state' => false, 'msg' => '帮派名称为空.');
        }else{
            $api = new ApiService($server);
            $info = $api->guildInfoList($name);

            if($info['state']){
                $data = $info['data'];

                foreach($data as $k=>&$v){
                    if(!empty($v)){
                        $v['members'] = explode(',', $v['members']);
                    }else{
                        unset($data[$k]);
                    }
                }
                unset($v);

                if(!empty($data)){
                    return array('state' => true, 'data' => $data);
                }else{
                    return array('state' => false, 'msg' => '找不到帮派信息.');
                }
            }else{
                return $info;
            }
        }
    }

}